<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="/../Thinkphp/Application/Home/View/User/jquery/jquery-3.0.0.js"></script>
        <script>
            $(function($){
                $('#phone').blur(function(){
                    var phone=$("#phone").val();                      
                    if(phone){                       
                        $("#text").text(" ");                       
                       if(!/^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/i.test(phone)){
                            $("#text").text("手机号错误");
                            $("p").css({"font-size" : "15px" , "color" :"red"});
                        }                  
                    }else{
                        $("#text").text("手机号不能为空");
                        $("p").css({"font-size" : "15px" , "color" :"red"});
                    }
                });
                $('#button').click(function(){                     
                    var phone=$("#phone").val(); 
                    if(phone){                    
                        var url="<?php print U('Home/test/send');?>";
                        var data={};
                        data['phone']=$("#phone").val(); 
                        var dataType="json";
                        $.post(
                            url,
                            data,                       
                            function(data){                                
                                if(data.status===1){
                                     $("#text").text(data.info);    
                                    $("p").css({"font-size" : "15px" , "color" :"blue"})
                                }
                            },
                            dataType
                        );
                           return false; 
                    } else{
                        $("#text").text("手机号不能为空");
                        $("p").css({"font-size" : "15px" , "color" :"red"});
                    }      
                    });
                    function settimeout(){
                        $("#button").removeAttr("disabled");
                    }
                $("#button").click(function(){
                     var phone=$("#phone").val();
                     if(phone){
                         $('#button').attr("disabled",true);                        
                     }      
                })
            });
        </script>
        
    </head>
    <body>
        <div>
            <form  action="<?php print U('Home/test/dotest');?>" method='post'>
                姓名:   <input type="text" name="username"></br>
                密码:   <input type="password" name="pass"></br>
                手机:   <input type="text" name="phone" id='phone'> 
                <p id='text'></p>
                <button type="button" id='button' >发送短信验证</button><br>
                验证码：<input type="text" name="captcha" id="captcha"/></br>	
                <input type='submit' value="确定" id='submit'>
            </form>
        </div>
    </body>
</html>